#pragma once
#include <iostream>
#include "Protocol.hpp"
#include <memory>
class NetCal
{
public:
    NetCal() {}
    ~NetCal() {}
    std::shared_ptr<Respence> CalWork(std::shared_ptr<Request> res)
    {
        std::shared_ptr<Respence> respence = Factor::BuildRespenceDefault();
        switch (res->GetOper())
        {
        case '+':
            respence->ModifyResult(res->GetX() + res->GetY());
            break;
        case '-':
            respence->ModifyResult(res->GetX() - res->GetY());
            break;
        case '*':
            respence->ModifyResult(res->GetX() * res->GetY());
            break;
        case '/':
            if (res->GetY() == 0)
            {
                respence->ModifyStatus("DIV_ZERO!", DIV_ZERO);
                break;
            }
            respence->ModifyResult(res->GetX() / res->GetY());
            break;
        case '%':
            if (res->GetY() == 0)
            {
                respence->ModifyStatus("MOD_ZERO!", MOD_ZERO);
                break;
            }
            respence->ModifyResult(res->GetX() % res->GetY());
            break;
        default:
            respence->ModifyStatus("Illegal_Operations!",Illegal_Operations);
            break;
        }
        return respence;
    }
};